﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Project01
{
    class Object
    {
        private Texture2D objTexture;
        public Texture2D ObjTexture
        {
            get { return objTexture; }
            set { objTexture = value; }
        }
        private Vector2 dimension;
        public Vector2 Dimension
        {
            get {return  dimension;}
            set { dimension = value;}
        }

        private Vector2 location;
        public Vector2 Location
        {
            get { return location; }
            set { location = value; }
        }

        private int mass;
        public int Mass
        {
            get { return mass; }
            set { mass = value; }
        }

        private Vector2 position;
        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        private Texture2D xCoordinate;
        public Texture2D XCoordinate
        { get { return xCoordinate; } }

        private Vector2 xCoorPosition;
        public Vector2 XCoorPosition
        { 
            get { return xCoorPosition; }
            set { xCoorPosition = value; }
        }

        private Texture2D yCoordinate;
        public Texture2D YCoordinate
        { get { return yCoordinate; } }

        private Vector2 yCoorPosition;
        public Vector2 YCoorPosition
        {
            get { return yCoorPosition; }
            set { yCoorPosition = value; }
        }

        private Vector2 objCenter;
        private Vector2 coorCenter;
        GraphicsDevice graphicDevice;

        private double momentOfInertiaCenter;
        public double MomentOfInertiaCenter
        { 
            get { return momentOfInertiaCenter; }
            set { momentOfInertiaCenter = value; }
        }

        private double distance;
        public double Distance
        { 
            get { return distance; }
            set { distance = value; }
        }

        private double momentOfInertiaCOM;
        public double MomentOfInertiaCOM
        {
            get { return momentOfInertiaCOM; }
            set { momentOfInertiaCOM = value; }
        }

        public Object(Vector2 dimension, Vector2 position, int mass, GraphicsDevice graphicDevice)
        {            
            this.dimension = dimension;
            this.position = position;
            this.mass = mass;

            this.graphicDevice = graphicDevice;
            objCenter = dimension / 2;
            coorCenter = new Vector2(240, 240);
            location.X = coorCenter.X + position.X;
            location.Y = coorCenter.Y - position.Y;
            location = location - objCenter;

            xCoordinate = CreateRectangle((int)Dimension.X,1, Color.White);
            xCoorPosition = new Vector2(Location.X, Location.Y + Dimension.Y/2);
            yCoordinate = CreateRectangle(1,(int)Dimension.Y, Color.White);
            yCoorPosition = new Vector2(Location.X + Dimension.X/2, Location.Y);
        }

        public Texture2D CreateRectangle(int width, int height, Color objColor)
        {
            Texture2D rectTexture = new Texture2D(graphicDevice, width, height, false, SurfaceFormat.Color);

            Color[] color = new Color[width * height];

            for (int i = 0; i < color.Length; i++)
                color[i] = objColor;

            rectTexture.SetData(color);

            return rectTexture;
        }
    }
}
